class CalendarSeeker {
	public static void main(String[] args) {
		UserInput input = new UserInput();
		//TEST START
		int[] date = {1, 1, 1583};
		int expectedWeekDay = 6;
		int[] finishDate = input.getDate("Please enter finish date:");
		boolean isTestPass = true;
		int weekDay;
		
		while (date[0] != finishDate[0] ||
			   date[1] != finishDate[1] ||
			   date[2] != finishDate[2]) {
			   
			weekDay = getWeekDay(date);
			//System.out.println("Tested value - week date for: " + Year.getVerbalDate(date));
			System.out.println("Expected result: " + expectedWeekDay);
			System.out.println("Actual result: " + weekDay);
			if (weekDay != expectedWeekDay) {
				isTestPass = false;
				System.out.println("Test failed for date: " +
					Year.getVerbalDate(date));
				break;
			}
			//increment date
			date[0] = date[0] + 1;
			if (date[0] > Year.getMonthLength(date[1], ((date[2] % 4 == 0 && date[2] % 100 != 0) || date[2] % 400 == 0))) {
				date[1] = date[1] + 1;
				date[0] = 1;
			}
			
			if (date[1] > 12) {
				date[2] = date[2] + 1;
				date[1] = 1;
			}
			//increment expectedWeekDay
			expectedWeekDay = expectedWeekDay + 1;
			if (expectedWeekDay > 6) {
				expectedWeekDay = 0;
			}
		}
		
		System.out.println("Test Result: " + (isTestPass ? "PASS" : "FAIL"));
	}
	
	static int getWeekDay(int[] date) {
		int temp_a;
		int temp_y;
		int temp_m;
		int result;
		temp_a = (14 - date[1])/12;
		temp_y = date[2] - temp_a;
		temp_m = date[1] + 12 * temp_a - 2;
		result = (7000 + (date[0] + temp_y + temp_y / 4 - temp_y / 100 + temp_y / 400 + 
					(31 * temp_m) / 12)) % 7;
		return result;
	}
}